package laba3;

import java.util.StringTokenizer;
import java.util.Vector;
import java.util.concurrent.Callable;

/**
 * Created by Mikhail on 06.05.14.
 * Parse a string to the vector of Integers.
 */
public class Parser implements Callable<Vector<Integer>>{
    String data;

    Parser(String s) {
        data = s;
    }

    @Override
    public Vector<Integer> call() throws Exception {
        StringTokenizer st = new StringTokenizer(data);
        Vector<Integer> arr = new Vector<Integer>();
        while (st.hasMoreTokens())
            try {
                arr.add(Integer.parseInt(st.nextToken()));
            } catch (NumberFormatException e) {}    //Если не число – пропустить
        return arr;
    }
}
